<#list pageInfo.list as item>
    <li class="_j_goods_li">
        <div class="info">
            <a href="" target="_blank">
                <img src="${item.img}"
                     alt="${item.name}">
                <div class="name">${item.name}<span class="${item.id}">剩余${item.num}</span></div>

            </a>
        </div>
        <div class="buy">
            <span><i class="icon_gold"></i>${item.score}</span>
            <a class="btn_buy <#if item.num ==0> _j_not_buy<#else> _j_buy</#if>" data-score="${item.score}"
               data-id="${item.id}">购买</a>
        </div>
    </li>
</#list>
<li class="coming_soon">
    <div class="info"></div>
</li>
<#include "../common/page.ftl">
<script>
    $('._j_not_buy').click(function () {
        $('#popup_container').css('display', 'block');
        $('#popup_container').css('opacity', '1');
        $('#popup_container').css('z-index', '1');
    })
    $('._j_close').click(function () {
        $('#popup_container').css('opacity', '0');
        $('#popup_container').css('z-index', '0');
        $('#popup_container').css('display', 'none');
        $('#score_container').css('display', 'none');
        $('#score_container').css('opacity', '0');
        $('#score_container').css('z-index', '0');
        $('#login_container').css('opacity', '0');
        $('#login_container').css('z-index', '0');
        $('#login_container').css('display', 'none');
    })
    $('._j_buy').click(function () {
        var id = $(this).data('id');
        var iscore = $(this).data('score');
        var uscore = $('#gold').data('score');
        var score = uscore - iscore;
        $('#gold').data('score', score);
        $.get('/itemshop/buy', {id: id}, function (data) {
            if (data.success) {
                $('#gold').html('<i></i>' + score);
                $.get('/itemshop/shopItem', function (data) {
                    $('#itemBox').empty();
                    $('#itemBox').html(data);
                });
            } else {
                <#if userInfo??>
                $('#score_container').css('display', 'block');
                $('#score_container').css('opacity', '1');
                $('#score_container').css('z-index', '1');
                <#else >
                $('#login_container').css('opacity', 'block');
                $('#login_container').css('opacity', '1');
                $('#login_container').css('z-index', '1');
                </#if>

            }
        })
    })
</script>
<div id="popup_container" class="popup-box new-popbox pop_no_margin"
     style="position: absolute; opacity: 0; background: rgb(255, 255, 255); z-index: 0; width: 420px;display: none;">
    <a class="close-btn _j_close"><i></i></a>
    <div class="pop-ico" id="_j_alertpopicon"><i class="i1"></i></div>
    <div class="pop-ctn"><p class="hd _j_content">不能购买</p>
        <p class="bd _j_detail"></p></div>
    <div class="pop-btns">
        <a role="button" tabindex="0" class="popbtn popbtn-submit _j_close">确定</a></div>
</div>
<link href="http://css.mafengwo.net/css/mfw-footer.css?1558532347" rel="stylesheet" type="text/css"/>

<div id="login_container" class="popup-box new-popbox pop_no_margin"
     style="position: absolute; opacity: 0; background: rgb(255, 255, 255); z-index: 0; width: 420px;display: none;">
    <a class="close-btn _j_close"><i></i></a>
    <div class="pop-ico" id="_j_alertpopicon"><i class="i1"></i></div>
    <div class="pop-ctn"><p class="hd _j_content">请先登录</p>
        <p class="bd _j_detail"></p></div>
    <div class="pop-btns">
        <a role="button" tabindex="0" class="popbtn popbtn-submit _j_close">确定</a></div>
</div>
<link href="http://css.mafengwo.net/css/mfw-footer.css?1558532347" rel="stylesheet" type="text/css"/>

<div id="score_container" class="popup-box new-popbox pop_no_margin"
     style="position: absolute; opacity: 0; background: rgb(255, 255, 255); z-index: 0; width: 420px; display: none;">
    <a class="close-btn _j_close"><i></i></a>
    <div class="pop-ico" id="_j_alertpopicon"><i class="i1"></i></div>
    <div class="pop-ctn"><p class="hd _j_content">金币不足，不能购买</p>
        <p class="bd _j_detail"></p></div>
    <div class="pop-btns">
        <a role="button" tabindex="0" class="popbtn popbtn-submit _j_close">确定</a></div>
</div>
<link href="http://css.mafengwo.net/css/mfw-footer.css?1558532347" rel="stylesheet" type="text/css"/>

